<?php

namespace Mlym\CodeGeneration\InitGeneration\Model;


use Mlym\CodeGeneration\ClassGeneration\ClassGeneration;
use Mlym\CodeGeneration\InitGeneration\Model\Method\GetSelectPage;
use Mlym\CodeGeneration\InitGeneration\Model\Method\Transaction;
use Mlym\CodeGeneration\InitGeneration\Model\ModelConfig;
use EasySwoole\ORM\AbstractModel;
use EasySwoole\ORM\DbManager;

class ModelGeneration extends ClassGeneration
{
    /**
     * @var $config ModelConfig
     */
    protected $config;

    public function __construct(?ModelConfig $config = null)
    {
        if (empty($config)) {
            $config = new ModelConfig("BaseModel", "App\\Model");
            $config->setExtendClass(AbstractModel::class);
        }
        parent::__construct($config);
    }

    function addClassData()
    {
        $this->addGenerationMethod(new GetSelectPage($this));

        $this->getPhpNamespace()->addUse(DbManager::class);
        $this->addGenerationMethod(new Transaction($this));
    }
}
